import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_framework_test/widget/timer_widget.dart';
import 'package:get/get.dart';

class DiscoveryPage extends StatefulWidget {
  const DiscoveryPage({super.key});

  @override
  State<DiscoveryPage> createState() => _DiscoveryPageState();
}

class _DiscoveryPageState extends State<DiscoveryPage> {
  Color _color = Colors.red;
  Color _colorUp = Colors.red;
  Color _colorDown = Colors.green;
  Color _colorBegin = Colors.red;
  Color _colorEnd = Colors.green;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.blue,
        centerTitle: true,
        title: const TimerWidget(
          tag: "appBar",
          seconds: 60,
          color: Colors.black,
        ),
      ),
      body: SafeArea(
        top: true,
        bottom: true,
        child: Row(
          children: [
            Expanded(
              flex: 1,
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    _color = _colorUp;
                    _colorBegin = _colorDown;
                    _colorEnd = _colorUp;
                  });
                  Future.delayed(Duration(seconds: 7), () {
                    setState(() {
                      _color = _colorUp;
                      _colorBegin = _colorUp;
                      _colorEnd = _colorDown;
                    });
                  });
                },
                child: Container(
                  padding: const EdgeInsets.all(3),
                  margin: const EdgeInsets.all(3),
                  height: double.infinity,
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      begin: Alignment.centerLeft,
                      end: Alignment.centerRight, //渐变结束于下面的中间
                      colors: [_colorBegin, _colorEnd],
                    ),
                    border: Border.all(color: _color, width: 0.5), // border
                    borderRadius: BorderRadius.circular((8)), // 圆角
                  ),
                  child: const Row(
                    children: [
                      Icon(Icons.watch_later),
                      Icon(Icons.watch_later_outlined),
                      Icon(Icons.watch_later_rounded),
                      Icon(Icons.watch_later_sharp),
                    ],
                  ),
                ),
              ),
            ),
            Expanded(
              flex: 1,
              child: Container(
                padding: const EdgeInsets.all(3),
                margin: const EdgeInsets.all(3),
                height: double.infinity,
                decoration: BoxDecoration(
                  color: Colors.black12, // 背景色
                  border: Border.all(
                      color: const Color(0xFFFF0000), width: 0.5), // border
                  borderRadius: BorderRadius.circular((8)), // 圆角
                ),
                child: Column(
                  children: [
                    const SizedBox(
                      height: 7,
                    ),
                    ElevatedButton(
                      onPressed: () {
                        Get.defaultDialog(
                            title: "Snackbar 标题",
                            content: Text("欢迎使用Snackbar"));
                      },
                      child: Text("显示 defaultDialog"),
                    ),
                    const SizedBox(
                      height: 7,
                    ),
                    ElevatedButton(
                      onPressed: () {
                        Get.snackbar("Snackbar 标题", "欢迎使用Snackbar",
                            snackPosition: SnackPosition.BOTTOM);
                      },
                      child: Text("显示 Snackbar"),
                    ),
                    SizedBox(
                      height: 7,
                    ),
                    ElevatedButton(
                        onPressed: () {
                          Get.bottomSheet(Container(
                            child: Wrap(
                              children: [
                                ListTile(
                                  leading: Icon(Icons.wb_sunny_outlined),
                                  title: Text("白天模式"),
                                  onTap: () {
                                    Get.changeTheme(ThemeData.light());
                                  },
                                ),
                                ListTile(
                                  leading: Icon(Icons.wb_sunny),
                                  title: Text("黑夜模式"),
                                  onTap: () {
                                    Get.changeTheme(ThemeData.dark());
                                  },
                                )
                              ],
                            ),
                          ));
                        },
                        child: Text("显示 Bottom Sheet"))
                  ],
                ),
              ),
            ),
            Expanded(
              flex: 1,
              child: Container(
                padding: const EdgeInsets.all(3),
                margin: const EdgeInsets.all(3),
                height: double.infinity,
                decoration: BoxDecoration(
                  color: Colors.black12, // 背景色
                  border: Border.all(
                      color: const Color(0xFFFF0000), width: 0.5), // border
                  borderRadius: BorderRadius.circular((8)), // 圆角
                ),
                child: const Row(
                  children: [
                    Icon(Icons.watch_later),
                    Icon(Icons.watch_later_outlined),
                    Icon(Icons.watch_later_rounded),
                    Icon(Icons.watch_later_sharp),
                  ],
                ),
              ),
            ),
            Expanded(
              flex: 1,
              child: Container(
                padding: const EdgeInsets.all(3),
                margin: const EdgeInsets.all(3),
                height: double.infinity,
                decoration: BoxDecoration(
                  color: Colors.black12, // 背景色
                  border: Border.all(
                      color: const Color(0xFFFF0000), width: 0.5), // border
                  borderRadius: BorderRadius.circular((8)), // 圆角
                ),
                child: const Row(
                  children: [
                    Icon(Icons.watch_later),
                    Icon(Icons.watch_later_outlined),
                    Icon(Icons.watch_later_rounded),
                    Icon(Icons.watch_later_sharp),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  void initState() {
    super.initState();
  }
}
